public class ClientClass {
    public static void main(String[] args) {
        Factory factory = new Factory();

        // 创建水果并存入集合
        factory.CreateFruit("A");
        factory.CreateFruit("B");

        // 使用迭代器遍历
        FruitIterator iterator = factory.getIterator();
        while(iterator.hasNext()) {
            Fruit fruit = iterator.next();
            fruit.eat();
        }
    }
}